import React, { Component, createContext } from 'react'

const { Provider, Consumer } = createContext()


function ComB() {
  return (
    <Consumer>
      {(val) => {
        return <div>ComB --- {val}</div>
      }}
    </Consumer>
  )
}

function ComA() {
  return (
    <div>
      ComA
      <ComB></ComB>
    </div>
  )
}



export default class App extends Component {
    constructor() {
    super()
    this.state = {
      age: 18
    }
  }
  

  
  render() {
    return (
      <Provider value={this.state.age}>
        <div>
          App3
          <ComA></ComA>
        </div>
      </Provider>
      
    )
  }

  componentDidMount() {
    console.log('didmount')
  }
}